package d0318;

import java.util.Date;

public class Join implements Runnable{
    private String name;
    private int sj;

    public Join(String name,int sj) {
        this.name = name;
        this.sj = sj;
    }

    @Override
    public void run() {
        System.out.println(name +"线程开始于："+new Date());//开始于时间
        try {
            Thread.sleep(sj);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(name +"线程结束于："+new Date());//开始于时间
    }

    public static void main(String[] args) {
        Thread thread1 = new Thread(new Join("one",3000));
        Thread thread2 = new Thread(new Join("two",4000));

        thread1.start();
        thread2.start();

        try {
            thread1.join();
            thread2.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("主线程结束");
    }
}